package router

import (
	. "gini2p/controllers"

	"github.com/gin-gonic/gin"
	"gini2p/middleware"
)

func RouterHroupBoth(r *gin.RouterGroup, path string, handler gin.HandlerFunc) {
	r.POST(path, handler)
	r.GET(path, handler)
}

func RouterBoth(r *gin.Engine, path string, handler gin.HandlerFunc) {
	r.POST(path, handler)
	r.GET(path, handler)
}

func AuthRouter(r *gin.Engine, path string, handler gin.HandlerFunc) {
	r.POST(path, middleware.BeforeRequestHandle(), handler)
	r.GET(path, middleware.BeforeRequestHandle(), handler)
}

func Init(r *gin.Engine) {
	site(r)
	parkinfo(r)
}

//site 路由
func site(r *gin.Engine) {
	RouterBoth(r, "site/login", Login)
}

func parkinfo(r *gin.Engine) {
	AuthRouter(r, "parkinfo/index", Index)
}
